<template>
    <div class='orderSetting'>
        <div class="container">
            <el-header>订单设置</el-header>
            <el-main>
                <el-form ref="form" :model="form" :rules="rules" label-width="180px" v-loading="formLoading" size="medium" style="margin-top:30px;">
                    <el-form-item label="秒杀订单超过：" prop="type">
                        <el-col :span="12">
                            <el-input v-model="form.type" placeholder="请输入">
                                <template slot="append">分</template>
                            </el-input>
                        </el-col>
                        <span style="position: absolute; left:56%; font-size: 14px; color:#8492a6;">未付款，订单自动关闭</span>
                    </el-form-item>
                    <el-form-item label="正常订单超过：" prop="type">
                        <el-col :span="12">
                            <el-input v-model="form.type" placeholder="请输入">
                                <template slot="append">分</template>
                            </el-input>
                        </el-col>
                        <span style="position: absolute; left:56%; font-size: 14px; color:#8492a6;">未付款，订单自动关闭</span>
                    </el-form-item>
                    <el-form-item label="发货超过：" prop="type">
                        <el-col :span="12">
                            <el-input v-model="form.type" placeholder="请输入">
                                <template slot="append">天</template>
                            </el-input>
                        </el-col>
                        <span style="position: absolute;left:56%; font-size: 14px; color:#8492a6;">未收货，订单自动完成</span>
                    </el-form-item>
                    <el-form-item label="订单完成超过：" prop="type">
                        <el-col :span="12">
                            <el-input v-model="form.type" placeholder="请输入">
                                <template slot="append">天</template>
                            </el-input>
                        </el-col>
                        <span style="position: absolute; left:56%; font-size: 14px; color:#8492a6;">自动结束交易，不能申请售后</span>
                    </el-form-item>
                    <el-form-item label="订单完成超过：" prop="type">
                        <el-col :span="12">
                            <el-input v-model="form.type" placeholder="请输入">
                                <template slot="append">天</template>
                            </el-input>
                        </el-col>
                        <span style="position: absolute; left:56%; font-size: 14px; color:#8492a6;">自动五星好评</span>
                    </el-form-item>
                </el-form>

                <el-row>
                    <el-col :span="20">
                        <el-button type="primary" @click="submit" :disabled="formLoading">提交</el-button>
                    </el-col>
                </el-row>
            </el-main>
            <!-- <el-footer>
                <el-button type="primary" @click="submit" :disabled="formLoading">确 定</el-button>
            </el-footer> -->
            <!-- <span slot="footer" class="dialog-footer">
                <el-button @click="close()">取 消</el-button>
                <el-button type="primary" @click="submit" :disabled="formLoading">确 定</el-button>
            </span> -->
        </div>
    </div>
</template>
<script>
// import { getMedicalListsAll, setMedical, setMedicalStatus, delMedical } from "@/api/basic/dataManage.js"
import { mhType, departStatus } from "@/api/dictionary"
import throttle from 'lodash.throttle'
export default {
    name: 'medicalHistoty',
    props: {

    },
    data() {
        return {
            showSearch: true,
            loading: false,
            pageCount: 0,
            total: 0,
            queryParams: {
                // page: 1,
                // limit: 20,
                type: '',
                is_show_hide: 1,
            },
            tableList: [],
            typeList: mhType,
            statusList: departStatus,
            handleShow: "",
            formLoading: false,
            form: {
                id: null,
                name: null,
                type: null,
            },
            rules: {
                type: [{ required: true, message: "请选择", trigger: "change" }],
                name: [{ required: true, message: '请输入病史名称', trigger: 'blur' }],
            },
        }
    },
    created() {
        this.getList()
        console.log(departStatus, "departStatus")
        console.log(mhType, "mhType")
    },
    methods: {
        getList() {
            // this.loading = true;
            // getMedicalListsAll(this.queryParams).then(res => {
            //     this.tableList = res.data;
            //     this.pageCount = res.data.pageCount;
            //     this.loading = false;
            // });
        },
        handleQuery() {
            this.queryParams.page = 1;
            this.getList();
        },
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        close() {
            this.form = {}
            this.handleShow = ""
        },
        toggleSelection(row) {
            this.$refs.tableList.toggleRowSelection(row);
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.selectData = selection;
        },
        handleBulk(ids) {
            this.$confirm('是否确认批量修改?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return delSector({ id: row.id });
            }).then(() => {
                this.getList();
                this.msgSuccess("修改成功");
            })
        },
        handleAble(row) {
            let label = row.status == 0 ? '停用' : '启用';
            this.$confirm(`是否将“${row.name}”${label}?`, "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return setMedicalStatus({ medical_id: row.id });
            }).then(() => {
                this.getList();
                this.msgSuccess(`${label}成功`);
            })
        },
        handleDelete(row) {
            this.$confirm('是否确认删除' + '"' + row.name + '"' + '?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return delMedical({ medical_id: row.id });
            }).then(() => {
                this.getList();
                this.msgSuccess("删除成功");
            })
        },
        submit: throttle(function () {
            this.$refs.form.validate((valid) => {
                if (valid) {
                    this.formLoading = true;
                    setMedical(this.form).then(res => {
                        this.msgSuccess("操作成功！");
                        this.close()
                        this.formLoading = false;
                        this.getList();
                    }).catch(() => {
                        this.formLoading = false;
                    })
                }
            })
        }, 1000, { trailing: false }),
    }
}
</script>

<style lang='scss' scoped>
.el-header {
    width: 70%;
    background-color: #F3F3F3;
    // color: #333;
    text-align: center;
    line-height: 60px;
}

.el-main {
    width: 70%;
    border: 1px solid #E4E4E4;
    text-align: center;
    line-height: 160px;
}
</style>
